package com.gin.no_gay_alliance.adpter.medal;

import android.content.Context;
import android.view.ViewGroup;

import androidx.annotation.NonNull;

import com.gin.nga.response.field.Medal;
import com.gin.no_gay_alliance.adpter.base.BaseBindingRecyclerViewAdapter;
import com.gin.no_gay_alliance.databinding.ItemMedalInTopicBinding;
import com.gin.no_gay_alliance.utils.ImageUtils;

import java.util.List;

/**
 * 徽章适配器
 *
 * @author : ginstone
 * @version : v1.0.0
 * @since : 2023/8/21 12:18
 **/
public class MedalAdapter extends BaseBindingRecyclerViewAdapter<ItemMedalInTopicBinding, Medal> {

    public MedalAdapter(Context context) {
        super(context);
    }

    public MedalAdapter(@NonNull Context context, @NonNull List<Medal> data) {
        super(context, data);
    }

    @Override
    protected void onBindViewHolder(ViewHolder<ItemMedalInTopicBinding> holder, @NonNull ItemMedalInTopicBinding b, int position, Medal item) {
        ImageUtils.loadMedal(context, item.getUrl(), b.iv);
    }

    /**
     * 根布局的宽高设置会丢失，需要重新配置
     *
     * @return
     */
    @Override
    protected ViewGroup.LayoutParams buildLayoutParamsForRoot() {
        return new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    }
}
